// 引入axios

import ajax from './ajax'
import mockAjax from './mockAjax'

//发送请求
//获取三级分类
export const reqCategoryListData = () => ajax.get('/product/getBaseCategoryList')
// console.log('打印这个',reqCategoryListData());

//获取轮播图数据
export const reqBannerListData = () => mockAjax.get('/banner')

//获取楼层
export const reqFloorsListData = () => mockAjax.get('/floors')

//获取搜索数据
export const reqSearchInfoData = (searchParams) => ajax.post('/list', searchParams)

//获取商品详情数据
export const reqGoodDetailInfoData = (id) => ajax.get(`/item/${id}`)

//添加到购物车
export const reqAddOrUpdateCart = (skuId, skuNum) => ajax.post(`/cart/addToCart/${skuId}/${skuNum}`)

//发送获取购物车中的商品数据
export const reqShopCartListData = () => ajax.get(`/cart/cartList`)

// 更改服务器端购物车中商品的选中与否的状态

export const reqChangeShopCartInfoState = (skuID, isChecked) => ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

//删除一件购物车的商品
export const reqDelOnShopCartInfo = (skuId) => ajax.delete(`/cart/deleteCart/${skuId}`)

//批量删除购物车中选中的商品
export const reqDelSelectedCartInfo = (cartInfo) => ajax.delete('/cart/batchDeleteCart', cartInfo)


//1.获取验证码
export const reqUserCode = (phone) => {
    return ajax({
        url: `user/passport/sendCode/${phone}`,
        method: 'get'
    })
}

//2.用户注册
export const reqUserRegister = (userInfo) => {
    return ajax({
        url: `user/passport/register`,
        method: 'post',
        data: userInfo
    })
}

//3.获取用户登录成功的token
export const reqUserToken = (user) => {
    return ajax({
        url: '/user/passport/login',
        method: 'post',
        data: user
    })
}
//4.根据用户token获取用户登录信息
export const reqUserLoginInfo = () => {
    return ajax({
        url: 'user/passport/auth/getUserInfo',
        method: 'get'
    })
}










